<style>
    img.fans-portrait{
        width:50px;
        height:50px;
    }
    .fsh-rightPanel .layui-table-body .layui-table-cell {
        height: 50px;
        line-height: 50px;
    }
</style>
<div class="fsh-rightPanel">
    <div class="layui-anim layui-anim-upbit">
        <div class="layui-form-item wx-search" id="list_form">
            <div class="layui-inline">
                <input type="text" name="nicknameStr" placeholder="请输入昵称" autocomplete="off" class="layui-input">
            </div>
            <button class="layui-btn btn-primary" id="search">搜索</button>
            <div class="layui-inline right">
                <button class="layui-btn btn-primary" onclick="jump('/miniapp/miniaccount/addaccount')">新  增</button>
            </div>
            
        </div>
        <table id="list_table" class="layui-hide" lay-filter="mainList"></table>
    </div>
</div>

<script>
    layui.use(['layer', 'table'], function () {
        var layer = layui.layer;
        var table = layui.table;

        debugger;
        var tableObj = table.render({
            id: 'list_table',
            elem: '#list_table',
            url: '/miniAppCorpBaseInfo/list',
            align: "center",
            cols: [[ //表头
                {type: 'checkbox'},
                {type: 'numbers', title: '序号',width:50},
                {field: 'name', title: '公司名称', width: 300, align: 'center',},
                {field: 'linkman', title: '联系人', width: 80, align: 'center',},
                {field: 'mobile', title: '电话号码', width: 100, align: 'center',},
                {field: 'authstatus', title: '是否认证', width: 100, align: 'center',templet:function (d) {
                    return d.authstatus == 1 ? '已认证' : '未认证';
                }},
                {field: 'authdate', title: '认证时间', width: 130, align: 'center',},
                {
                    field: 'lock', title: '操作', width: 200, align: 'center', templet: function (d) {
                        return '<a href="javascript:;" class="font-primary" lay-event="detail">详情</a><a href="javascript:;" class="font-primary" lay-event="delete">删除</a>';
                    }, unresize: true, align: 'center',
                }
            ]],
        });

        // 检索
        $("#search").click(function () {
            reloadTable(tableObj);
        });

     // 添加
        $("#mini_add").click(function () {
            showDialog({
                title: '添加',
                template: 'add',
                saveUrl: '/msgtext/updateText',
                tableObj: tableObj,
                beforeSubmit: function (data) {
                    if (!data.path) {
                        layer.msg("请上传视频");
                        return false;
                    }
                    return true;
                }
            })
        });

        //表格内部操作按钮监听
        table.on('tool(mainList)', function (obj) { //注：tool是工具条事件名，mainList是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值

            if (layEvent === 'delete') {
	            	layer.confirm('确认删除该条信息？', {
	                    icon: 7,
	                    title: "提示",
	                    btn: ['确认', '取消'] //按钮
	                }, function () {
	                    $.ajax({
	                        url: '/miniAppCorpBaseInfo/deleteById',
	                        data: {id: data.id},
	                        success: function (result) {
	                            if (result) {
	                                layer.msg("删除成功");
	                                reloadTable(tableObj);
	                            }
	                        },
	                        error: function () {
	                            layer.msg("删除异常");
	                        }
	                    })
	                }, function () {
	                    layer.closeAll();
	                });
            }
        });

    });
</script>
